<template>
	<view class="messageDetails">
		<view class="content">
			<view class="top">
				<text>{{info.title}}</text>
				<text>{{info.time}}</text>
			</view>
			<view class="info">
				{{info.content}}
			</view>
		</view>
	</view>
</template>

<script>
	import serve from '../../static/request.js';
	import storage from '../../static/appkey.js';
	import common from '../../static/jump.js';
	export default {
		data() {
			return {
				id : 0,
				info: {},
			}
		},
		methods: {
			getInfo() {
				serve
					.request({
						url: '/member/message/view',
						data: {
							appkey: uni.getStorageSync('appkey'),
							'access-token': uni.getStorageSync('access-token'),
							id : this.id
						}
					})
					.then(res => {
						if(res.code != 200) {
							uni.showToast({
								title: res.message,
								icon: 'none',
								success() {
									setTimeout(function () {
										this.jump('message_index')
									}, 2000) 
								}
							});
						}
						this.info = res.data;
					});
			},
			jump(jump_type, jump_link){
				common.jump(jump_type, jump_link);
			}
		},
		onLoad(options) {
			this.id = options.id || 0;
			if(this.id == 0) {
				uni.showToast({
					title: "错误的访问方式",
					icon: 'none',
					success() {
						setTimeout(function () {
							common.jump('message_index')
						}, 2000) 
					}
				});
			}
			this.getInfo();
		},
		onPullDownRefresh() {
			this.getInfo();
		}
	}
</script>

<style scoped lang="scss">
	.messageDetails {
		.content {
			box-sizing: border-box;
			padding: 0rpx 0rpx 0rpx 30rpx;

			.top {
				display: flex;
				flex-direction: column;
				box-sizing: border-box;
				padding: 48rpx 11rpx;
				font-size: 36rpx;
				font-weight: bold;
				border-bottom: 1rpx rgba(57, 72, 107, 0.1) solid;

				text:last-child {
					font-size: 24rpx;
					color: rgba(60, 72, 104, 0.5);
					margin-top: 35rpx;
					font-weight: 400;
				}
			}
			.info{
				box-sizing: border-box;
				padding: 36rpx 40rpx 36rpx 10rpx;
				font-size:32rpx;
			}
		}
	}
</style>
